<template>
  <div class="select-wrap">
    <ul class="c-list">
      <router-link class="c-list-i" :to="''" tag="li" v-for="item in list" :key="item.id" exact>
        <div class="avatar-wrap"><span class="userhead" :style="'background-image:url(' + item.userhead + ')'"></span></div>
        <div class="username-wrap vux-1px-b">{{item.username}}</div>
      </router-link>
    </ul>
    <toast v-model="err" type="text" :text="errtxt"></toast>
  </div>
</template>

<script>
  import { Toast } from 'vux'
  export default{
    components: { Toast },
    data() {
      return {
        list: [],
        err: false,
        errtxt: ''
      }
    },
    created() {
      let req = {
        id: this.$route.params.id
      }
      this.$http.post('/studentslist', req).then(res => {
        if (res.body.error_code) {
          this.err = true
          this.errtxt = error_msg
          return
        }
        this.list = res.body.res.list
      })
    }
  }
</script>

<style lang="less">
  .c-list {
    &-i {
      display: table;
      width: 100%;
      height: 56px;
      line-height: 56px;
      font-size: 0;
    }
    .avatar-wrap,
    .username-wrap{
      display: table-cell;
      vertical-align: middle;
    }

    .avatar-wrap {
      width: 52px;
      padding-left: 14px;
      text-align: center;
    }
    .username-wrap {
      font-size: 16px;
      color: #333;
    }

    .userhead {
      display: block;
      width: 36px;
      height: 36px;
      background: #ddd no-repeat center;
      background-size: 100% auto;
      border-radius: 50%;
    }
  }
</style>
